import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';
import '../index.dart';
import 'package:leader_help/utils/util.dart';

class QuestionDetailTabsView extends GetView<QuestionDetailController> {
  const QuestionDetailTabsView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<QuestionDetailController>(
      builder: (logic) => Container(
        color: ColorsUtil.bg,
        child: Wrap(
          alignment: WrapAlignment.spaceEvenly,
          spacing: 0.5,
          children: controller.state.tabTitles
              .asMap()
              .map(
                (key, value) => MapEntry(
                  key,
                  MenuItemView(
                    onTap: () => controller.actionActive(key),
                    color: Colors.white,
                    width: (Get.width - 20.r - 3) / 4,
                    padding: EdgeInsets.symmetric(vertical: 15.r),
                    icon: Icon(
                      value.iconData,
                      size: 30.r,
                      color: key == controller.state.tabActiveIndex
                          ? ColorsUtil.red
                          : ColorsUtil.title,
                    ),
                    title: Text(
                      value.name,
                      style: pfMediumStyle(
                          color: key == controller.state.tabActiveIndex
                              ? ColorsUtil.red
                              : ColorsUtil.title,
                          fontSize: 13.r),
                    ),
                  ),
                ),
              )
              .values
              .toList(),
        ),
      ),
    );
  }
}
